/**
 * <p>Copyright:Copyright(c) 2019</p>
 * <p>Company:Professional</p>
 * <p>Package:org.cesgroup.course.api.bo</p>
 * <p>File:UserBoProxy.java</p>
 * <p>类更新历史信息</p>
 * @todo chanlong(陈龙) 创建于 Sep 4, 2019 5:14:49 PM
 */
package org.cesgroup.course.api.bo;

import org.cesgroup.course.api.po.User;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.MD5;

/**
 * <p>描述: </p>
 * <p>Company: Professional</p>
 * @author chanlong(陈龙)
 * @date Sep 4, 2019 5:14:49 PM
 * @version 1.0.2019
 */
// 用户Bo的代理
public class UserBoProxy implements IUserBo {
	
	// 代理中加入目标对象引用
	private IUserBo target;
	
	public UserBoProxy(IUserBo target) {
		this.target = target;
	}
	
	/**
	 * @see org.cesgroup.course.api.bo.IUserBo#save(org.cesgroup.course.api.po.User)
	 * @author chanlong(陈龙)
	 * @date Sep 4, 2019 5:14:49 PM
	 */
	@Override
	public User save(final User user) {
		// 对前台传递的密码明文进行加密，若密码为空则使用默认密码
		String password = user.getPassword();
		user.setPassword(MD5.create().digestHex(StrUtil.isEmpty(password) ? "000000" : password));
		return target.save(user);
	}

	/**
	 * @see org.cesgroup.course.api.bo.IUserBo#findAll()
	 * @author chanlong(陈龙)
	 * @date Sep 4, 2019 5:14:49 PM
	 */
	@Override
	public Iterable<User> findAll() {
		return null;
	}

}
